<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>layui布局列表</title>
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css" />
    <!-- 引入 layui.js -->
    <script src="jquery-3.6.1.min.js"></script>
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
  </head>
  <body>
    <div class="layui-layout layui-layout-admin">
      <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">佩奇</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
          <!-- 移动端显示 -->
        <!-- <ul class="layui-nav layui-layout-left">
        
          <li
            class="layui-nav-item layui-show-xs-inline-block layui-hide-sm"
            lay-header-event="menuLeft"
          >
            <i class="layui-icon layui-icon-spread-left"></i>
          </li>
          <li class="layui-nav-item layui-hide-xs"><a href="">nav 1</a></li>
          <li class="layui-nav-item layui-hide-xs"><a href="">nav 2</a></li>
          <li class="layui-nav-item layui-hide-xs"><a href="">nav 3</a></li>
          <li class="layui-nav-item">
            <a href="javascript:;">nav groups</a>
            <dl class="layui-nav-child">
              <dd><a href="">menu 11</a></dd>
              <dd><a href="">menu 22</a></dd>
              <dd><a href="">menu 33</a></dd>
            </dl>
          </li>
        </ul> -->
        <ul class="layui-nav layui-layout-right">
          <li class="layui-nav-item layui-hide layui-show-md-inline-block">
            <a href="javascript:;">
              <img
                src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                class="layui-nav-img"
              />
              <span class="xspan">tester</span>
            </a>
            <dl class="layui-nav-child">
              <dd><a href="">个人信息</a></dd>
              <dd><a href="javascript:;" id="tuichu">退出登录</a></dd>
              <dd><a href="">弹弹弹 弹走鱼尾纹</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
            <a href="javascript:;">
              <i class="layui-icon layui-icon-more-vertical"></i>
            </a>
          </li>
        </ul>
      </div>

      <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
          <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
          <ul class="layui-nav layui-nav-tree" lay-filter="test" >
            <li class="layui-nav-item layui-this" lay-header-event="menuLeft" data-url="个人数据.html">
              <a href="javascript:;">后台主页</a>
            </li>
            <li class="layui-nav-item" >
              <a class="" href="javascript:;">用户管理</a>
              <dl class="layui-nav-child">
                <dd lay-header-event="menuLeft"  data-url="分页用户列表.html"><a href="javascript:;" >用户信息</a></dd>
                <dd lay-header-event="menuLeft" data-url="index.html"><a href="javascript:;">添加用户</a></dd>
              </dl>
            </li>
            <li class="layui-nav-item">
              <a href="javascript:;">商品管理</a>
              <dl class="layui-nav-child">
                <dd lay-header-event="menuLeft" data-url="添加商品.html"><a href="javascript:;">添加商品</a></dd>
                <dd lay-header-event="menuLeft" data-url="商品表格.html"><a href="javascript:;">商品列表</a></dd>
              </dl>
            </li>
            <li class="layui-nav-item">
              <a href="javascript:;">成绩管理</a>
              <dl class="layui-nav-child">
                <dd lay-header-event="menuLeft" data-url="二段成绩.html"><a href="javascript:;">二段成绩</a></dd>
                <dd lay-header-event="menuLeft" data-url="三段成绩.html"><a href="javascript:;">三段成绩</a></dd>
              </dl>
            </li>
          </ul>
        </div>
      </div>

      <div class="layui-body">
        <!-- 内容主体区域 -->
        <iframe id="ifrm" style="width: 100%; height:100%;" src="个人数据.html" frameborder="0"></iframe>
      </div>

      <div class="layui-footer">
        <!-- 底部固定区域 -->
        底部固定区域
      </div>
    </div>
  </body>
  <script>
    //JS
    layui.use(["element", "layer", "util"], function () {
      var element = layui.element,
        layer = layui.layer,
        util = layui.util,
        $ = layui.$;

      //头部事件
      util.event("lay-header-event", {
        //左侧菜单事件
        menuLeft: function (othis) {
        var url=$(othis).attr('data-url')
          $('#ifrm').attr('src',url)
        },
      });
    });
  </script>
  <script>
    $(function () {
      xuanran();
      kaijucaozuo()
      $("#tuichu").click(tuichuFun);
    });
    //退出
    function tuichuFun() {
      localStorage.removeItem("user");
      xuanran();
    }
    function kaijucaozuo(){
      $('.layui-body')
    }
    //渲染
    function xuanran() {
      var data = JSON.parse(localStorage.getItem("user"));
      if (data == null) {
        alert("请先登录");
        location.href = "登录注册.html";
        return false;
      }
      $(".xspan").html(data.username);
    }
  </script>
</html>
